using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Container : MonoBehaviour
{

    public static Container instance;

    public int ID;

    List<IMessager> messagerList;

    public int NextID { get { return ID++; } }

    void Awake()
    {
        if (null == instance)
        {
            instance = this;
            ID = 10000;
            messagerList = new List<IMessager>();
        }
        else
            DestroyObject(this);
    }

    public IMessager GetMessagerFromID(int ID)
    {
        return messagerList.Find(ret => ret.ID == ID);
    }

    public void RegisterMessager(IMessager mgr)
    {
        if (!messagerList.Contains(mgr))
            messagerList.Add(mgr);
    }

    public void RemoveMessager(IMessager mgr)
    {
        if (messagerList.Contains(mgr))
            messagerList.Remove(mgr);
    }
}
